{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 第2章 感知机"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1．感知机是根据输入实例的特征向量$x$对其进行二类分类的线性分类模型：\n",
    "\n",
    "$$\n",
    "f(x)=\\operatorname{sign}(w \\cdot x+b)\n",
    "$$\n",
    "\n",
    "感知机模型对应于输入空间（特征空间）中的分离超平面$w \\cdot x+b=0$。\n",
    "\n",
    "2．感知机学习的策略是极小化损失函数：\n",
    "\n",
    "$$\n",
    "\\min _{w, b} L(w, b)=-\\sum_{x_{i} \\in M} y_{i}\\left(w \\cdot x_{i}+b\\right)\n",
    "$$\n",
    "\n",
    "损失函数对应于误分类点到分离超平面的总距离。\n",
    "\n",
    "3．感知机学习算法是基于随机梯度下降法的对损失函数的最优化算法，有原始形式和对偶形式。算法简单且易于实现。原始形式中，首先任意选取一个超平面，然后用梯度下降法不断极小化目标函数。在这个过程中一次随机选取一个误分类点使其梯度下降。\n",
    " \n",
    "4．当训练数据集线性可分时，感知机学习算法是收敛的。感知机算法在训练数据集上的误分类次数$k$满足不等式：\n",
    "\n",
    "$$\n",
    "k \\leqslant\\left(\\frac{R}{\\gamma}\\right)^{2}\n",
    "$$\n",
    "\n",
    "当训练数据集线性可分时，感知机学习算法存在无穷多个解，其解由于不同的初值或不同的迭代顺序而可能有所不同。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 二分类模型\n",
    "$f(x) = sign(w\\cdot x + b)$\n",
    "\n",
    "$\\operatorname{sign}(x)=\\left\\{\\begin{array}{ll}{+1,} & {x \\geqslant 0} \\\\ {-1,} & {x<0}\\end{array}\\right.$\n",
    "\n",
    "给定训练集：\n",
    "\n",
    "$T=\\left\\{\\left(x_{1}, y_{1}\\right),\\left(x_{2}, y_{2}\\right), \\cdots,\\left(x_{N}, y_{N}\\right)\\right\\}$\n",
    "\n",
    "定义感知机的损失函数 \n",
    "\n",
    "$L(w, b)=-\\sum_{x_{i} \\in M} y_{i}\\left(w \\cdot x_{i}+b\\right)$\n",
    "\n",
    "---\n",
    "#### 算法\n",
    "\n",
    "随即梯度下降法 Stochastic Gradient Descent\n",
    "\n",
    "随机抽取一个误分类点使其梯度下降。\n",
    "\n",
    "$w = w + \\eta y_{i}x_{i}$\n",
    "\n",
    "$b = b + \\eta y_{i}$\n",
    "\n",
    "当实例点被误分类，即位于分离超平面的错误侧，则调整$w$, $b$的值，使分离超平面向该无分类点的一侧移动，直至误分类点被正确分类"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "拿出iris数据集中两个分类的数据和[sepal length，sepal width]作为特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.datasets import load_iris\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# load data\n",
    "iris = load_iris()\n",
    "df = pd.DataFrame(iris.data, columns=iris.feature_names)\n",
    "df['label'] = iris.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2    50\n",
       "1    50\n",
       "0    50\n",
       "Name: label, dtype: int64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns = [\n",
    "    'sepal length', 'sepal width', 'petal length', 'petal width', 'label'\n",
    "]\n",
    "df.label.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x212128c3da0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAY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WT/H7aaEnkio+cYfb9ZR7hPwWpH0q7A7yPiCuBTZI9k7gPmKF/TV9KAtl2AZbTf4XVkM09uBHYkWxIRik9seBPwnjEzdi6c5Pg7gNdL+i+StmPbx1SPk921mCXnf2FYHe1D1jH7LLAZeFdEPC3pWOBCSTuS/bd/AfDT/D2/lfQDsnW3R/sZPkn2+Oh0smf8RXwsP/+aPDE8AIy7bnBEjEj6OHA72fz49wAb85evBC6VdBrZLKBmyXiWVOt7km4F3h8RQz2O40UR8UR+p/A14PMR0bxwu1lSfnxkVh5nS7qbbOGfX1HBpSSt+nynYGZmDb45Mg6qAAAAJklEQVRTMDOzBicFMzNrcFIwM7MGJwUzM2twUjAzswYnBTMza/j/pgzYEDEDapEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x21210866630>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(df[:50]['sepal length'], df[:50]['sepal width'], label='0')\n",
    "plt.scatter(df[50:100]['sepal length'], df[50:100]['sepal width'], label='1')\n",
    "plt.xlabel('sepal length')\n",
    "plt.ylabel('sepal width')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.array(df.iloc[:100, [0, 1, -1]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "X, y = data[:,:-1], data[:,-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "y = np.array([1 if i == 1 else -1 for i in y])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Perceptron"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据线性可分，二分类数据\n",
    "# 此处为一元一次线性方程\n",
    "class Model:\n",
    "    def __init__(self):\n",
    "        self.w = np.ones(len(data[0]) - 1, dtype=np.float32)\n",
    "        self.b = 0\n",
    "        self.l_rate = 0.1\n",
    "        # self.data = data\n",
    "\n",
    "    def sign(self, x, w, b):\n",
    "        y = np.dot(x, w) + b\n",
    "        return y\n",
    "\n",
    "    # 随机梯度下降法\n",
    "    def fit(self, X_train, y_train):\n",
    "        is_wrong = False\n",
    "        while not is_wrong:\n",
    "            wrong_count = 0\n",
    "            for d in range(len(X_train)):\n",
    "                X = X_train[d]\n",
    "                y = y_train[d]\n",
    "                if y * self.sign(X, self.w, self.b) <= 0:\n",
    "                    self.w = self.w + self.l_rate * np.dot(y, X)\n",
    "                    self.b = self.b + self.l_rate * y\n",
    "                    wrong_count += 1\n",
    "            if wrong_count == 0:\n",
    "                is_wrong = True\n",
    "        return 'Perceptron Model!'\n",
    "\n",
    "    def score(self):\n",
    "        pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Perceptron Model!'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "perceptron = Model()\n",
    "perceptron.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x21212a24128>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VOX1+PHPIQFCAEFZBAkhbLKLLCKKigpuiEC/asVqKy6lBa1ra39WQEVxa23VWrGodQO3ugCi4IKKUh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V9ZTSnlbC/XuBT1T1F+Is2fppBcIQ4OLIKlqHNoqcjHOGUCgf5/9hRRd5KjxG4fON8YT1KZi4IyLHAdmqOhH4G84lmaVAI4ms2ysi1eXIRVYK+x1Ow5lxchfOlOobIo8Pq2AY7wN/OGxWzm7l7D8X6CsiR4sznfvhl6n24Jy1GOM7+wvDxKMuOB2zBUAuMEJVD4rIJcDjIlIP59/+o8DCyHN2iMgXOOtgF/YzPIxz+ehWnGv8FXFv5Pg/RBLDGqDUtYFVdYOI3A/MwZkXfxHOioDgrKXxtIjciDPTpzG+sVlSTcITkU+BP6rqvIDjqKOqeyNnCm8D/1HV4gu2G+Mru3xkTHjcLSLf4Szas5qQLxdp4pOdKRhjjCliZwrGGGOKWFIwxhhTxJKCMcaYIpYUjDHGFLGkYIwxpoglBWOMMUX+PzG5AZSnCCLVAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x212129e33c8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_points = np.linspace(4, 7, 10)\n",
    "y_ = -(perceptron.w[0] * x_points + perceptron.b) / perceptron.w[1]\n",
    "plt.plot(x_points, y_)\n",
    "\n",
    "plt.plot(data[:50, 0], data[:50, 1], 'bo', color='blue', label='0')\n",
    "plt.plot(data[50:100, 0], data[50:100, 1], 'bo', color='orange', label='1')\n",
    "plt.xlabel('sepal length')\n",
    "plt.ylabel('sepal width')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### scikit-learn实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import Perceptron"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\stochastic_gradient.py:183: FutureWarning: max_iter and tol parameters have been added in Perceptron in 0.19. If max_iter is set but tol is left unset, the default value for tol in 0.19 and 0.20 will be None (which is equivalent to -infinity, so it has no effect) but will change in 0.21 to 1e-3. Specify tol to silence this warning.\n",
      "  FutureWarning)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Perceptron(alpha=0.0001, class_weight=None, early_stopping=False, eta0=1.0,\n",
       "      fit_intercept=False, max_iter=1000, n_iter=None, n_iter_no_change=5,\n",
       "      n_jobs=None, penalty=None, random_state=0, shuffle=False, tol=None,\n",
       "      validation_fraction=0.1, verbose=0, warm_start=False)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf = Perceptron(fit_intercept=False, max_iter=1000, shuffle=False)\n",
    "clf.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  74.6 -127.2]]\n"
     ]
    }
   ],
   "source": [
    "# Weights assigned to the features.\n",
    "print(clf.coef_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.]\n"
     ]
    }
   ],
   "source": [
    "# 截距 Constants in decision function.\n",
    "print(clf.intercept_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x21212d57e48>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvN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plain": [
       "<matplotlib.figure.Figure at 0x21212d297f0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_ponits = np.arange(4, 8)\n",
    "y_ = -(clf.coef_[0][0]*x_ponits + clf.intercept_)/clf.coef_[0][1]\n",
    "plt.plot(x_ponits, y_)\n",
    "\n",
    "plt.plot(data[:50, 0], data[:50, 1], 'bo', color='blue', label='0')\n",
    "plt.plot(data[50:100, 0], data[50:100, 1], 'bo', color='orange', label='1')\n",
    "plt.xlabel('sepal length')\n",
    "plt.ylabel('sepal width')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----\n",
    "参考代码：https://github.com/wzyonggege/statistical-learning-method\n",
    "\n",
    "中文注释制作：机器学习初学者\n",
    "\n",
    "微信公众号：ID:ai-start-com\n",
    "\n",
    "配置环境：python 3.5+\n",
    "\n",
    "代码全部测试通过。\n",
    "![gongzhong](../gongzhong.jpg)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
